import request from '@/utils/request'

// 1.获取角色列表
export const reqGetRoleList = (page = 1, pagesize = 10) => {
  return request({
    method: 'get',
    url: '/sys/role',
    params: {
      page,
      pagesize
    }
  })
}

// 2.根据id删除角色
export const reqDelRole = (id) => {
  return request({
    method: 'delete',
    url: `/sys/role/${id}`
  })
}

// 3.新增角色
export const reqAddRole = (data) => {
  return request({
    method: 'post',
    url: '/sys/role',
    data
  })
}

// 4 根据 id 获取角色详情, 用于回显
export function reqGetRoleDetail(id) {
  return request({
    method: 'get',
    url: `/sys/role/${id}`
  })
}

// 5 修改角色
export function reqUpdateRole(data) {
  return request({
    method: 'put',
    url: `/sys/role/${data.id}`,
    data
  })
}
// 给角色分配权限
export function reqAssignPerm(data) {
  return request({
    url: '/sys/role/assignPrem',
    method: 'put',
    data
  })
}

